<template>
  <div>
    <van-cell-group>
      <van-field v-model="user.userName" label="用户名" placeholder="请输入用户名" />
      <van-field v-model="user.pwd" type="password" label="密码框" placeholder="请输入用户名" />
    </van-cell-group>
    <van-button type="info" size="large" @click="login">登录</van-button>
  </div>
</template>

<script>
export default {
  data () {
    return {
      user: {
        userName: '',
        pwd: ''
      }
    }
  },
  methods: {
    login () {
      setTimeout(() => {
        const token = 'dwidijdiw39456treosjx'
        // 存储 后台返回 token
        localStorage.setItem('access_token', token)
        // 回到 重定向之前的 路由
        if (this.$route.params.from) {
          this.$router.push(this.$route.params.from)
        } else {
          this.$router.push('/home')
        }
      }, 1000)
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
